package com.automannn.atm_back.modules.system.entity;

import com.automannn.atm_back.common.aspect.annotation.Dict;
import com.automannn.atm_back.config.jackson.AtmBooleanDeserializer;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.deser.std.NumberDeserializers;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * @author chenkh
 * @time 2020/6/26 16:32
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SysPermission implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(type = IdType.ID_WORKER_STR)
    private String id;

    /**
     * 父id
     */
    private String parentId;

    /**
     * 菜单名称
     */
    private String name;

    /**
     * 菜单权限编码，例如：“sys:schedule:list,sys:schedule:info”,多个逗号隔开
     */
    private String perms;
    /**
     * 权限策略1显示2禁用
     */
    private String permsType;

    /**
     * 菜单图标
     */
    private String icon;

    /**
     * 组件
     */
    private String component;

    /**
     * 组件名字
     */
    private String componentName;

    /**
     * 路径
     */
    private String url;
    /**
     * 一级菜单跳转地址
     */
    private String redirect;

    /**
     * 菜单排序
     */
    private Double sortNo;

    /**
     * 类型（0：一级菜单；1：子菜单 ；2：按钮权限）
     */
    @Dict(dicCode = "menu_type")
    private Integer menuType;

    /**
     * 是否叶子节点: 1:是  0:不是
     */
    @JsonDeserialize(using = AtmBooleanDeserializer.class)
    @TableField(value="is_leaf")
    private String leaf;

    /**
     * 是否路由菜单: 0:不是  1:是（默认值1）
     */
    @JsonDeserialize(using = AtmBooleanDeserializer.class)
    @TableField(value="is_route")
    private String route;


    /**
     * 是否缓存页面: 0:不是  1:是（默认值1）
     */
    @JsonDeserialize(using = AtmBooleanDeserializer.class)
    @TableField(value="keep_alive")
    private String keepAlive;

    /**
     * 描述
     */
    private String description;

    /**
     * 创建人
     */
    private String createUser;

    /**
     * 删除状态 0正常 1已删除
     */
    private Integer delFlag;

    /**
     * 是否配置菜单的数据权限 1是0否 默认0
     */
    private Integer ruleFlag;

    /**
     * 是否隐藏路由菜单: 0否,1是（默认值0）
     */
    @JsonDeserialize(using = AtmBooleanDeserializer.class)
    private String hidden;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新人
     */
    private String updateUser;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**按钮权限状态(0无效1有效)*/
    @JsonDeserialize(using = AtmBooleanDeserializer.class)
    private String status;

    /**alwaysShow*/
    @JsonDeserialize(using = AtmBooleanDeserializer.class)
    private String alwaysShow;

    /*update_begin author:wuxianquan date:20190908 for:实体增加字段 */
    /** 外链菜单打开方式 0/内部打开 1/外部打开 */
    @JsonDeserialize(using = AtmBooleanDeserializer.class)
    private String internalOrExternal;
    /*update_end author:wuxianquan date:20190908 for:实体增加字段 */

    public SysPermission() {

    }
    public SysPermission(boolean index) {
        if(index) {
            this.id = "9502685863ab87f0ad1134142788a385";
            this.name="首页";
            this.component="dashboard/Analysis";
            this.componentName="dashboard-analysis";
            this.url="/dashboard/analysis";
            this.icon="home";
            this.menuType=0;
            this.sortNo=0.0;
            this.ruleFlag=0;
            this.delFlag=0;
            this.alwaysShow="0";
            this.route="1";
            this.keepAlive="1";
            this.leaf="1";
            this.hidden="0";
        }

    }
}
